package com.tanhua.server.interceptor;

import com.tanhua.domain.db.User;

import java.util.List;

public class UserHolder {
    private static ThreadLocal<User> tl = new ThreadLocal<>();
    private static ThreadLocal<String> tokenTl = new ThreadLocal<>();
    private static ThreadLocal<List<Long>> blackListTL = new ThreadLocal<>();
    private static ThreadLocal<List<Long>> friendTL = new ThreadLocal<>();

    //setUser
    public static void setUser(User user) {
        tl.set(user);
    }

    //getUser
    public static User getUser() {
        return tl.get();
    }

    //removeUser
    public static void removeUser() {
        tl.remove();
    }

    public static void setToken(String token) {
        tokenTl.set(token);
    }

    public static String getToken() {
        return tokenTl.get();
    }

    public static void removeToken() {
        tokenTl.remove();
    }

    //黑名单操作
    public static void setBlackList(List<Long> blackListIdList) {
        blackListTL.set(blackListIdList);
    }

    public static List<Long> getBlackList() {
        return blackListTL.get();
    }

    public static void removeBlackList() {
        blackListTL.remove();
    }

    //好友关系操作
    public static void setFriend(List<Long> frindIdList) {
        friendTL.set(frindIdList);
    }

    public static List<Long> getFriend() {
        return friendTL.get();
    }

    public static void removeFriend() {
        friendTL.remove();
    }
}
